//
//  ShowBigHeaderPicViewController.m
//  安好
//
//  Created by 马晓良 on 14-12-11.
//  Copyright (c) 2014年 lianchuangbrother. All rights reserved.
//

#import "ShowBigHeaderPicViewController.h"

@interface ShowBigHeaderPicViewController ()
//  头像
@property (strong, nonatomic) UIImageView *headerImageView;

@end

@implementation ShowBigHeaderPicViewController

- (UIImageView *)headerImageView{
    if (_headerImageView == nil) {
        _headerImageView = [[UIImageView alloc] initWithImage:self.headerImage];
        _headerImageView.userInteractionEnabled = YES;
        [self.view addSubview:_headerImageView];
    }
    return _headerImageView;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor lightGrayColor];
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapHandelAction:)];
    tap.numberOfTapsRequired = 1;
    [self.headerImageView addGestureRecognizer:tap];
    [self.view addGestureRecognizer:tap];
    CGFloat imageWidth = self.headerImage.size.width;
    CGFloat imageHeigh = self.headerImage.size.height;
    CGFloat viewWidth = kScreenWidth;
    CGFloat viewHeith = kScreenHeight;
    
    if (imageWidth < viewWidth && imageHeigh < viewHeith) {
        self.headerImageView.frame = CGRectMake((viewWidth-imageWidth)/2, (viewHeith-imageHeigh)/2, imageWidth, imageHeigh);
        
    }else if (imageWidth < viewWidth && imageHeigh > viewHeith){
        self.headerImageView.frame = CGRectMake((viewWidth-imageWidth)/2, 0, imageWidth, imageHeigh);
        
    }else if (imageWidth > viewWidth && imageHeigh < viewHeith){
        self.headerImageView.frame = CGRectMake(0, (viewHeith-imageHeigh)/2, imageWidth, imageHeigh);
        
    }else if (imageWidth > viewWidth && imageHeigh > viewHeith){
        self.headerImageView.frame = CGRectMake(0, 0, imageWidth, imageHeigh);
    }

    // Do any additional setup after loading the view from its nib.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)tapHandelAction:(UIGestureRecognizer *)sender{
    [self dismissViewControllerAnimated:YES completion:nil];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
